{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import os.path\n",
    "import random\n",
    "import numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#icvl\n",
    "subject_names = [\"Test1\", \"Test2\", \"201403121135\", \"201403121140\", \"201405151126\", \"201406030937\",\n",
    "                         \"201406031456\", \"201406031503\", \"201406031747\", \"201406041509\", \"201406181554\", \"201406181600\",\n",
    "                         \"201406191014\", \"201406191044\"]\n",
    "TEST_SUBJECT_NUM = 2\n",
    "data_dir='/home/cyj/Human_analysis/data/ICVL/process_output'\n",
    "dataset_list_train=[]\n",
    "dataset_list_train_label=[]\n",
    "dataset_list_test=[]\n",
    "'''\n",
    "#Test data\n",
    "testlist_dir=os.path.join(data_dir,'test_list.txt')\n",
    "for i_subject in range(TEST_SUBJECT_NUM):\n",
    "    cur_data_dir = os.path.join(data_dir, subject_names[i_subject])\n",
    "    print(\"Testing: \" + cur_data_dir)\n",
    "    #self.__loaddata(cur_data_dir)\n",
    "    # add /pc/.npz to dataset_list_test\n",
    "    lists_cur = os.listdir(os.path.join(cur_data_dir, 'pc'))\n",
    "    lists_cur.sort(key=lambda x: int(x[:-4]))\n",
    "    for list_cur in lists_cur:\n",
    "        list_path = os.path.join(subject_names[i_subject], 'pc',list_cur)\n",
    "        dataset_list_test.append(list_path)\n",
    "with open(testlist_dir,'w') as fp:\n",
    "    for line in dataset_list_test:\n",
    "        fp.write(line)\n",
    "        fp.write('\\n')\n",
    "'''\n",
    "'''\n",
    "for i_subject in range(len(subject_names)):\n",
    "    if i_subject >= TEST_SUBJECT_NUM:\n",
    "        cur_data_dir = os.path.join(data_dir, subject_names[i_subject])\n",
    "        print(\"Training: \" + cur_data_dir)\n",
    "        lists_cur = os.listdir(os.path.join(cur_data_dir, 'pc'))\n",
    "        lists_cur.sort(key=lambda x: int(x[:-4]))\n",
    "        for list_cur in lists_cur:\n",
    "            list_path = os.path.join(subject_names[i_subject], 'pc',list_cur)\n",
    "            dataset_list_train.append(list_path)\n",
    "\n",
    "#Train data: Use 100%, Label 50%\n",
    "use_ratio=1\n",
    "label_ratio=0.5#in use_ratio\n",
    "trainlist_dir=os.path.join(data_dir,'train_list_shuffle_%.1f_%.1f.txt'%(use_ratio,label_ratio))\n",
    "label_trainlist_dir=os.path.join(data_dir,'train_label_shuffle_list_%.1f_%.1f.txt'%(use_ratio,label_ratio))\n",
    "list_len=int(len(dataset_list_train)*use_ratio)\n",
    "label_list_len=int(list_len*label_ratio)\n",
    "new_trainlist=random.sample(dataset_list_train,list_len)\n",
    "label_trainlist=random.sample(new_trainlist,label_list_len)\n",
    "with open(trainlist_dir,'w') as fp:\n",
    "    for line in new_trainlist:\n",
    "        fp.write(line)\n",
    "        fp.write('\\n')\n",
    "with open(label_trainlist_dir,'w') as fp:\n",
    "    for line in label_trainlist:\n",
    "        fp.write(line)\n",
    "        fp.write('\\n')\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
